package com.ruoyi.web.cp.service;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.web.core.config.ConfigLoader;
import com.ruoyi.web.cp.domain.rm.ObGame;
import com.ruoyi.web.cp.domain.rm.RmGame;
import com.ruoyi.web.cp.model.Game;
import com.ruoyi.web.cp.service.http.ObHttpService;
import com.ruoyi.web.cp.service.ob.ObGameService;
import com.ruoyi.web.mapper.ObGameMapper;
import com.ruoyi.web.mapper.RmGameMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;

@Slf4j
@Service
public class ObService {
    @Autowired
    private ObHttpService httpService;
    @Autowired
    private ConfigLoader configLoader;
    @Autowired
    private WinxinService winxinService;
    @Autowired
    private RmGameMapper rmGameMapper;
    private static Integer count = 0;
    @Autowired
    private ObGameService obGameService;
    @Autowired
    private ObGameMapper obGameMapper;


    /**
     * @Description: 获取ob列表
     * @Author: xiesm
     * @Date: 2025/3/21
     */
    public Set<String> getObList() {
        String path = configLoader.getRmPath() + "ob-game.txt";

        Set<String> games = new LinkedHashSet<>();

        JSONArray datas = new JSONArray();
        datas.fluentAdd("livedata").fluentAdd("nolivedata");
        JSONObject res = httpService.sendObList(datas);
        if (CollUtil.isEmpty(res)) {
            return games;
        }
        count = 0;
        JSONArray livedata = res.getJSONObject("data").getJSONArray("livedata");
        JSONArray onlivedata = res.getJSONObject("data").getJSONArray("nolivedata");
        livedata.addAll(onlivedata);
        String text = "{}\t{}\t{}\t{}\t{}";
        List<String> list = new ArrayList<>();
        try {
            List<ObGame> obGames = new ArrayList<>();
            for (int i = 0; i < livedata.size(); i++) {
                try {
                    JSONObject jsonObject = livedata.getJSONObject(i);
                    if (jsonObject.getString("mids").trim().length() > 7) {
                        continue;
                    }
                    String mids = jsonObject.getString("mids").trim();
                    JSONObject data = httpService.sendObListDetail(mids, true);
                    String mhn = data.getJSONObject("data").getString("mhn").trim(); //主队
                    String man = data.getJSONObject("data").getString("man").trim(); //客队
                    String tn = data.getJSONObject("data").getString("tn").trim(); //联赛
                    Long mgt = data.getJSONObject("data").getLong("mgt"); //时间
                    Date date1 = new Date(mgt);
                    String date = DateUtil.format(date1, "yyyy-MM-dd HH:mm:ss");
                    String name = StrUtil.format(text, mids, tn, date, mhn, man);
                    if (System.currentTimeMillis() > mgt) {
                        continue;
                    }
                    if (data.getString("isNew") != null) {
                        log.info(name);
                    }
                    if (!tn.contains("VS-") && !tn.contains("梦幻对垒") && !tn.contains("8分钟")) {
                        list.add(name);
                        games.add(name);
                    }
                    ObGame obGame = new ObGame(mids, date1, tn, mhn, man);
                    obGames.add(obGame);

                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                }
            }
            obGameService.saveObGames(obGames);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        } finally {
            if (CollUtil.isNotEmpty(list)) {
                FileUtil.writeLines(list, path, "utf8");
            }
        }
        return games;
    }

    private static List<String> cleanFileNames = Arrays.asList(
            "ob-gameScore.txt",
            "ob-gameScore-accurate.txt",
            "ob-gameScore-half.txt",
            "ob-gameScore-double.txt",
            "ob-gameScore-dy.txt",
            "ob-gameScore-dx2.txt"
    );

    /**
     * @Description: 获取rm详情
     * @Author: xiesm
     * @Date: 2025/3/21
     */
    public synchronized void getObDetail() {
        log.info("======> 获取ob详情开始");
        long beginTime = System.currentTimeMillis();
        List<String> games = FileUtil.readLines(configLoader.getRmPath() + "ob-game.txt", "utf8");

        for (int i = 0; i < cleanFileNames.size(); i++) {
            FileUtils.clearFile(configLoader.getRmPath() + cleanFileNames.get(i));
        }

        Map<String, String> rmobDict = Game.getRmobDict();

        List<RmGame> rmGames = rmGameMapper.selectRecentGames2();
        Map<String, String> gameIdToRmGameMap = rmGames.stream()
                .collect(Collectors.toMap(
                        rmGame -> rmGame.getTeamA() + rmGame.getTeamB(),
                        rmGame -> rmGame.getGameId(),
                        (existing, replacement) -> existing
                ));

        String text = "{}\t{}";
        for (String game : games) {
            try {
                List<String> list = new ArrayList<>();
                List<String> list2 = new ArrayList<>();
                List<String> list3 = new ArrayList<>();
                List<String> listDouble = new ArrayList<>();
                List<String> listDy = new ArrayList<>();
                List<String> listX2 = new ArrayList<>();

                list.add(game);
                list2.add(game);
                list3.add(game);
                listDouble.add(game);
                listDy.add(game);
                listX2.add(game);

                String[] split = game.split("\t");
                String mid = split[0];
                JSONObject data = httpService.sendObDetail(mid, game, true);
                if ("0401013".equals(data.get("code"))) {
                    log.error("ob-token过期," + count);
                    if ((count++ % 20) == 0) {
                        winxinService.sendTextMessage("1000004", "ob-token过期");
                    }
                    return;
                }
                JSONArray datas = data.getJSONArray("data");
                if (CollUtil.isEmpty(datas)) {
                    continue;
                }

                JSONObject cache = new JSONObject();
                getCache(datas, cache);
                for (int j = 0; j < datas.size(); j++) {
                    JSONObject json = datas.getJSONObject(j);
                    String hpn = json.getString("hpn");
                    if ("全场波胆".equals(hpn)) {
                        JSONArray hls = json.getJSONArray("hl");
                        for (int k = 0; k < hls.size(); k++) {
                            JSONObject hl = hls.getJSONObject(k);
                            JSONArray ols = hl.getJSONArray("ol");
                            for (int l = 0; l < ols.size(); l++) {
                                JSONObject ol = ols.getJSONObject(l);
                                String on = ol.getString("on").trim();
                                String ov = ol.getString("ov").trim();
                                BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                                if (getScores().contains(on)) {
                                    String str = StrUtil.format(text, on, plv);
                                    list.add(str);
                                    cache.put(on, plv);
                                }
                            }
                        }
                    }
                    if ("全场独赢".equals(hpn)) {
                        JSONArray hls = json.getJSONArray("hl");
                        for (int k = 0; k < hls.size(); k++) {
                            JSONObject hl = hls.getJSONObject(k);
                            JSONArray ols = hl.getJSONArray("ol");
                            for (int l = 0; l < ols.size(); l++) {
                                JSONObject ol = ols.getJSONObject(l);
                                String ot = ol.getString("ot").trim();
                                String ov = ol.getString("ov").trim();
                                BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                                switch (ot) {
                                    case "X":
                                        cache.put("平", plv);
                                        break;
                                    case "1":
                                        cache.put("主胜", plv);
                                        break;
                                    case "2":
                                        cache.put("主负", plv);
                                        break;
                                }
                                if (StrUtil.equalsIgnoreCase("x", ot)) {
                                    getStr(json, text, listDy, "ot", "ov", "dy", cache);
                                }
                            }
                        }
                    }
                    if ("半场/全场 & 准确进球数".equals(hpn)) {
                        getStr(json, text, list2, "ot", "ov", "accurate", cache);
                    }
                    if ("上半场-波胆".equals(hpn)) {
                        getStr(json, text, list3, "on", "ov", "half", cache);
                    }

                }
                for (int j = 0; j < datas.size(); j++) {
                    JSONObject json = datas.getJSONObject(j);
                    String hpn = json.getString("hpn");
                    if ("两队都进球".equals(hpn)) {
                        getStr(json, text, listDouble, "ott", "ov", "double", cache);
                        JSONArray hls = json.getJSONArray("hl");
                        for (int k = 0; k < hls.size(); k++) {
                            JSONObject hl = hls.getJSONObject(k);
                            JSONArray ols = hl.getJSONArray("ol");
                            for (int l = 0; l < ols.size(); l++) {
                                JSONObject ol = ols.getJSONObject(l);
                                String ot = ol.getString("ot").trim();
                                String ov = ol.getString("ov").trim();
                                BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                                switch (ot) {
                                    case "Yes":
                                        cache.put("双进是", plv);
                                        break;
                                    case "No":
                                        cache.put("双进否", plv);
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                    }
                }
                listX2.add(StrUtil.format("{}\t{}", cache.get("大小"), cache.get("0-0")));

                if (list.size() > 1) {
                    list.add(StrUtil.format("双进\t{}", cache.get("双进是")));
                    list.add(StrUtil.format("大小\t{}", cache.get("大小")));
                    if (cache.get("让球") != null) {
                        String str = cache.getString("让球");
                        str = str.replace("-", "让").replace("+", "受让");
                        list.add(StrUtil.format("亚盘\t{}", str));
                    }
                }

                FileUtil.writeLines(list, configLoader.getRmPath() + "ob-gameScore.txt", "utf8", true);
                FileUtil.writeLines(list2, configLoader.getRmPath() + "ob-gameScore-accurate.txt", "utf8", true);
                FileUtil.writeLines(list3, configLoader.getRmPath() + "ob-gameScore-half.txt", "utf8", true);
                FileUtil.writeLines(listDouble, configLoader.getRmPath() + "ob-gameScore-double.txt", "utf8", true);
                FileUtil.writeLines(listDy, configLoader.getRmPath() + "ob-gameScore-dy.txt", "utf8", true);
                FileUtil.writeLines(listX2, configLoader.getRmPath() + "ob-gameScore-dx2.txt", "utf8", true);

                String teamA = rmobDict.get(split[3]);
                String teamB = rmobDict.get(split[4]);
                String rmGameId = gameIdToRmGameMap.get(
                        (teamA == null ? split[3] : teamA) +
                                (teamB == null ? split[4] : teamB));

                RmGame.ObDetail obDetail = getObDetail(cache);
                if (rmGameId != null) {
                    List<RmGame.ObDetail> obDetails = new ArrayList<>();
                    obDetails.add(obDetail);
                    rmGameMapper.updateOddsByGameId(new RmGame(rmGameId, obDetails));
                }
                obGameMapper.updateDetailsByGameId(JSONObject.toJSONString(obDetail), mid);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
            }
        }
        log.info(StrUtil.format("======> 获取ob详情结束,耗时:{}", (System.currentTimeMillis() - beginTime)));
    }

    public static void getCache(JSONArray datas, JSONObject cache) {
        for (int i = 0; i < datas.size(); i++) {
            JSONObject data = datas.getJSONObject(i);
            String hpn = data.getString("hpn");
            JSONArray hls = data.getJSONArray("hl");
            String hpid = data.getString("hpid");
            for (int k = 0; k < hls.size(); k++) {
                JSONObject hl = hls.getJSONObject(k);
                JSONArray ols = hl.getJSONArray("ol");
                for (int l = 0; l < ols.size(); l++) {
                    JSONObject ol = ols.getJSONObject(l);
                    String ott = ol.getString("ott").trim();
                    String ov = ol.getString("ov").trim();
                    String on = ol.getString("on").trim();
                    BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                    if ("否".equals(ott)) {
                        switch (hpid) {
                            case "83":
                                cache.put("主-上下半场全胜-否", plv);
                                break;
                            case "93":
                                cache.put("客-上下半场全胜-否", plv);
                                break;
                            case "375":
                                cache.put("主-上半场零失球获胜-否", plv);
                                break;
                            case "376":
                                cache.put("客-上半场零失球获胜-否", plv);
                                break;
                            case "381":
                                cache.put("主-下半场零失球获胜-否", plv);
                                break;
                            case "382":
                                cache.put("客-下半场零失球获胜-否", plv);
                                break;
                            case "82":
                                cache.put("主-全场零失球获胜-否", plv);
                                break;
                            case "80":
                                cache.put("客-全场零失球获胜-否", plv);
                                break;
                            case "81":
                                cache.put("主-全场零失球-否", plv);
                                break;
                            case "79":
                                cache.put("客-全场零失球-否", plv);
                                break;
                            case "86":
                                cache.put("主-上下半场均进球-否", plv);
                                break;
                            case "96":
                                cache.put("客-上下半场均进球-否", plv);
                                break;
                            default:
                                break;
                        }
                    }
                    if ("是".equals(ott)) {
                        switch (hpid) {
                            case "86":
                                cache.put("主-上下半场均进球-是", plv);
                                break;
                            case "96":
                                cache.put("客-上下半场均进球-是", plv);
                                break;
                            default:
                                break;
                        }
                    }
                    switch (hpid) {
                        case "367":
                            JSONObject qcFbdan = (JSONObject) cache.getOrDefault("全场反波胆", new JSONObject());
                            cache.putIfAbsent("全场反波胆", qcFbdan);
                            qcFbdan.put(on, plv);
                            break;
                        case "368":
                            JSONObject sbcFbdan = (JSONObject) cache.getOrDefault("上半场反波胆", new JSONObject());
                            cache.putIfAbsent("上半场反波胆", sbcFbdan);
                            sbcFbdan.put(on, plv);
                            break;
                        case "369":
                            JSONObject xbcFbdan = (JSONObject) cache.getOrDefault("下半场反波胆", new JSONObject());
                            cache.putIfAbsent("下半场反波胆", xbcFbdan);
                            xbcFbdan.put(on, plv);
                            break;
                        default:
                            break;
                    }
                }
            }
            if ("上半场让球".equals(hpn)) {
                for (int k = 0; k < hls.size(); k++) {
                    JSONObject hl = hls.getJSONObject(k);
                    if (!"1".equals(hl.getString("hn"))) {
                        continue;
                    }
                    JSONArray ols = hl.getJSONArray("ol");
                    for (int l = 0; l < ols.size(); l++) {
                        JSONObject ol = ols.getJSONObject(l);
                        String on = ol.getString("on").trim();
                        String ot = ol.getString("ot").trim();
                        String ov = ol.getString("ov").trim();
                        BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                        switch (ot) {
                            case "1":
                                cache.put("半场主让球胜", plv);
                                cache.put("半场让球", on);
                                break;
                            case "2":
                                cache.put("半场主让球负", plv);
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            if ("上半场大小".equals(hpn)) {
                for (int k = 0; k < hls.size(); k++) {
                    JSONObject hl = hls.getJSONObject(k);
                    if (!"1".equals(hl.getString("hn"))) {
                        continue;
                    }
                    JSONArray ols = hl.getJSONArray("ol");
                    for (int l = 0; l < ols.size(); l++) {
                        JSONObject ol = ols.getJSONObject(l);
                        String on = ol.getString("on").trim();
                        String ot = ol.getString("ot").trim();
                        String ov = ol.getString("ov").trim();
                        cache.put("半场大小", on);
                        BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                        switch (ot) {
                            case "Over":
                                cache.put("半场大", plv);
                                break;
                            case "Under":
                                cache.put("半场小", plv);
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            if ("全场让球".equals(hpn)) {
                for (int k = 0; k < hls.size(); k++) {
                    JSONObject hl = hls.getJSONObject(k);
                    if (!"1".equals(hl.getString("hn"))) {
                        continue;
                    }
                    JSONArray ols = hl.getJSONArray("ol");
                    for (int l = 0; l < ols.size(); l++) {
                        JSONObject ol = ols.getJSONObject(l);
                        String on = ol.getString("on").trim();
                        String ot = ol.getString("ot").trim();
                        String ov = ol.getString("ov").trim();
                        BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                        switch (ot) {
                            case "1":
                                cache.put("主让球胜", plv);
                                cache.put("让球", on);
                                break;
                            case "2":
                                cache.put("主让球负", plv);
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            if ("全场反波胆".equals(hpn)) {
                for (int k = 0; k < hls.size(); k++) {
                    JSONObject hl = hls.getJSONObject(k);
                    JSONArray ols = hl.getJSONArray("ol");
                    for (int l = 0; l < ols.size(); l++) {
                        JSONObject ol = ols.getJSONObject(l);
                        String on = ol.getString("on").trim();
                        String ov = ol.getString("ov").trim();
                        if ("0-0".contains(on)) {
                            BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                            cache.put("反" + on, plv);
                        }
                    }
                }
            }
            if ("全场大小".equals(hpn)) {
                for (int k = 0; k < hls.size(); k++) {
                    JSONObject hl = hls.getJSONObject(k);
                    if (!"1".equals(hl.getString("hn"))) {
                        continue;
                    }
                    JSONArray ols = hl.getJSONArray("ol");
                    for (int l = 0; l < ols.size(); l++) {
                        JSONObject ol = ols.getJSONObject(l);
                        String on = ol.getString("on").trim();
                        String ot = ol.getString("ot").trim();
                        String ov = ol.getString("ov").trim();
                        cache.put("大小", on);
                        BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                        switch (ot) {
                            case "Over":
                                cache.put("大", plv);
                                break;
                            case "Under":
                                cache.put("小", plv);
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
            if ("全场大小".equals(hpn)) {
                for (int k = 0; k < hls.size(); k++) {
                    JSONObject hl = hls.getJSONObject(k);
                    if (!"1".equals(hl.getString("hn"))) {
                        continue;
                    }
                    JSONArray ols = hl.getJSONArray("ol");
                    for (int l = 0; l < ols.size(); l++) {
                        JSONObject ol = ols.getJSONObject(l);
                        String on = ol.getString("on").trim();
                        String ot = ol.getString("ot").trim();
                        String ov = ol.getString("ov").trim();
                        cache.put("大小", on);
                        BigDecimal plv = new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP);
                        switch (ot) {
                            case "Over":
                                cache.put("大", plv);
                                break;
                            case "Under":
                                cache.put("小", plv);
                                break;
                            default:
                                break;
                        }
                    }
                }
            }
        }
    }

    public static RmGame.ObDetail getObDetail(JSONObject cache) {
        RmGame.ObDetail obDetail = new RmGame.ObDetail();
        obDetail.setBdan00_plv(cache.getString("0-0"));
        obDetail.setDouble_plv(cache.getString("双进是"));
        obDetail.setGoal_desc(cache.getString("大小"));
        obDetail.setGoal_half_desc(cache.getString("半场大小"));
        obDetail.setWin_plv(cache.getString("主胜"));
        obDetail.setDraw_plv(cache.getString("平"));
        obDetail.setLose_plv(cache.getString("主负"));
        obDetail.setAsian_desc(cache.getString("让球"));
        obDetail.setAsian_big_plv(cache.getString("主让球胜"));
        obDetail.setAsian_small_plv(cache.getString("主让球负"));
        obDetail.setAsian_half_desc(cache.getString("半场让球"));
        obDetail.setAsian_half_big_plv(cache.getString("半场主让球胜"));
        obDetail.setAsian_half_small_plv(cache.getString("半场主让球负"));
        obDetail.setSx_all_win_plv_teamA(cache.getString("主-上下半场全胜-否"));
        obDetail.setSx_all_win_plv_teamB(cache.getString("客-上下半场全胜-否"));
        obDetail.setS_ling_win_plv_teamA(cache.getString("主-上半场零失球获胜-否"));
        obDetail.setS_ling_win_plv_teamB(cache.getString("客-上半场零失球获胜-否"));
        obDetail.setX_ling_win_plv_teamA(cache.getString("主-下半场零失球获胜-否"));
        obDetail.setX_ling_win_plv_teamB(cache.getString("客-下半场零失球获胜-否"));
        obDetail.setSx_ling_win_plv_teamA(cache.getString("主-全场零失球获胜-否"));
        obDetail.setSx_ling_win_plv_teamB(cache.getString("客-全场零失球获胜-否"));
        obDetail.setAll_ling_plv_teamA(cache.getString("主-全场零失球-否"));
        obDetail.setAll_ling_plv_teamB(cache.getString("客-全场零失球-否"));
        obDetail.setSx_have_goal_plv_t_teamA(cache.getString("主-上下半场均进球-是"));
        obDetail.setSx_have_goal_plv_t_teamB(cache.getString("客-上下半场均进球-是"));
        obDetail.setSx_have_goal_plv_teamA(cache.getString("主-上下半场均进球-否"));
        obDetail.setSx_have_goal_plv_teamB(cache.getString("客-上下半场均进球-否"));
        obDetail.setQc_fbdan_plv(cache.getJSONObject("全场反波胆"));
        obDetail.setSbc_fbdan_plv(cache.getJSONObject("上半场反波胆"));
        obDetail.setXbc_fbdan_plv(cache.getJSONObject("下半场反波胆"));
        return obDetail;
    }

    private static JSONArray getScores() {
        JSONArray scores = new JSONArray();
        scores.fluentAdd("0-0").fluentAdd("1-1").fluentAdd("2-2").fluentAdd("3-3");
        scores.fluentAdd("0-1").fluentAdd("0-2").fluentAdd("0-3");
        scores.fluentAdd("1-0").fluentAdd("2-0").fluentAdd("3-0");
        scores.fluentAdd("1-2").fluentAdd("1-3");
        scores.fluentAdd("2-1").fluentAdd("3-1");
        scores.fluentAdd("2-3");
        scores.fluentAdd("3-2");
        return scores;
    }

    private static JSONArray getHalfScores() {
        JSONArray scores = new JSONArray();
        scores.fluentAdd("0-0").fluentAdd("1-1").fluentAdd("2-2");
        scores.fluentAdd("0-1").fluentAdd("0-2");
        scores.fluentAdd("1-0").fluentAdd("2-0");
        scores.fluentAdd("1-2");
        scores.fluentAdd("2-1");
        return scores;
    }

    private static void getStr(JSONObject json, String text, List<String> list, String key1,
                               String key2, String flag, JSONObject cache) {
        JSONArray hls = json.getJSONArray("hl");
        for (int k = 0; k < hls.size(); k++) {
            JSONObject hl = hls.getJSONObject(k);
            JSONArray ols = hl.getJSONArray("ol");
            for (int l = 0; l < ols.size(); l++) {
                JSONObject ol = ols.getJSONObject(l);
                String on = ol.getString(key1);
                String ov = ol.getString(key2).trim();
                String str = StrUtil.format(text, on, new BigDecimal(ov).divide(new BigDecimal("100000"), 2, RoundingMode.HALF_UP));
                if ("half".equals(flag) && getHalfScores().contains(on)) {
                    list.add(str);
                } else if ("accurate".equals(flag)) {
                    list.add(str);
                } else if ("double".equals(flag)) {
                    if ("是".equals(on)) {
                        //是、双进、波胆00、大小球、大球赔率，小球赔率、独赢胜赔率、独赢平赔率、独赢负赔率、让球、主让球胜赔率、主让球负赔率
                        str = str + "\t" + cache.get("0-0")
                                + "\t" + cache.get("大小")
                                + "\t" + cache.get("大")
                                + "\t" + cache.get("小")
                                + "\t" + cache.get("主胜")
                                + "\t" + cache.get("平")
                                + "\t" + cache.get("主负")
                                + "\t" + cache.get("让球")
                                + "\t" + cache.get("主让球胜")
                                + "\t" + cache.get("主让球负")
                        ;
                    }
                    list.add(str);
                } else if ("dy".equals(flag)) {
                    list.add(str);
                } else if ("dx2".equals(flag)) {
                    list.add(str);
                }
            }
        }
    }
}
